﻿Imports System.Collections.Generic
Imports EnvDTE
Imports System.Linq
Imports EnvDTE80
Imports System.Runtime.CompilerServices

Module Extensions

  Public Enum ePropertyName
    FullPath
    Subtype
    IsLink
  End Enum

  Private Const PROPERTY_FULL_PATH As String = "FullPath"
  Private Const PROPERTY_SUBTYPE As String = "Subtype"
  Private Const PROPERTY_ISLINK As String = "IsLink"

  <Extension()> _
  Public Function TryGetPropertyValue(item As ProjectItem, propertyName As ePropertyName) As String
    Dim propName = GetPropertyName(propertyName)

    Dim ret = item.TryGetPropertyValue(propName)
    Return ret
  End Function

  <Extension()> _
  Public Function TryGetPropertyValue(item As ProjectItem, propertyName As String) As String

    Dim ret As String
    Try
      ret = CType(item.Properties.Item(propertyName).Value, String)
    Catch ex As Exception
      ret = Nothing
    End Try
    Return ret

    Return ret
  End Function

  Private Function GetPropertyName(propertyEnumValue As ePropertyName) As String
    Select Case propertyEnumValue
      Case ePropertyName.FullPath
        Return "FullPath"
      Case ePropertyName.IsLink
        Return "IsLink"
      Case ePropertyName.Subtype
        Return "Subtype"
      Case Else
        Throw New NotImplementedException()
    End Select
  End Function


End Module
